from Page.Page2 import Page2
from selenium.webdriver.common.by import By

class Page5(Page2):
    shou_loc = (By.XPATH, '/html/body/div[3]/div[2]/ul/li[1]/a')
    def shou(self):
        self.click(self.shou_loc)

    search_loc = (By.XPATH, '//input[@class="search-input" or @name="keywords"]')
    def search(self):
        self.send_keys(self.search_loc, '非洲之心')

    searchbtn_loc = (By.XPATH, '//*[@id="searchForm"]/div[2]/input')
    def searchbtn(self):
        self.click(self.searchbtn_loc)

    shopping_loc = (By.XPATH, '//img[@src="/uploads/images/20250606/af9ef24936d60ea1dfe55120bccc1906.png"]')
    def shopping(self):
        self.click(self.shopping_loc)

    addgwc_loc = (By.ID,'add-cart')
    def addgwc(self):
        self.click(self.addgwc_loc)

    gwc_loc = (By.CLASS_NAME,'nav-settcart')
    def gwc(self):
        self.click(self.gwc_loc)

    delete_loc = (By.CLASS_NAME,'cart-delete')
    def delete(self):
        self.click(self.delete_loc)

    dy6_loc = (By.XPATH,'//*[@id="layui-layer1"]/div[2]')
    def dy6(self):
        dy6 = self.text(self.dy6_loc)
        print(dy6)

    sure_loc = (By.XPATH,'//*[@id="layui-layer1"]/div[3]/a[1]')
    def sure(self):
        self.click(self.sure_loc)

    def luoji_A3amll_gwc(self):
        try:
            self.luoji_A3mall_login()
            self.shou()
            self.search()
            self.searchbtn()
            self.shopping()
            self.sleep(1)
            self.addgwc()
            self.sleep(2)
            self.gwc()
            self.delete()
            self.sleep(1)
            self.dy6()
            self.sure()
        except Exception as e:
            print(e)
            self.screenshot()